package com.agency8x.controller;

import com.agency8x.bean.SearchParamBean;
import com.agency8x.interceptor.CheckLoginInterceptor;
import com.agency8x.model.RechargeModel;
import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
import com.jfinal.kit.StrKit;

/**
 * 充值页面控制器
 * @author SoChishun
 *
 */
@Before(CheckLoginInterceptor.class)
public class RechargeController extends Controller {
	
	// 获取和设置查询参数
	private SearchParamBean getAndSetQueryParams(){
		SearchParamBean bean=new SearchParamBean();
		bean.setWord(getPara("word", ""));
		bean.setDate1(getPara("date1", ""));
		bean.setDate2(getPara("date2", ""));
		this.setAttr("word", bean.getWord());
		this.setAttr("date1", bean.getDate1());
		this.setAttr("date2", bean.getDate2());
		return bean;
	}
	
	public void index(){
		SearchParamBean search=getAndSetQueryParams();
		setAttr("listPage", RechargeModel.me.paginate(getParaToInt(0, 1), 10,search.getWord(),search.getDate1(),search.getDate2(),null));
		// 设置传入分页的url参数
		this.setAttr("append", search.getQueryString());
		this.render("index.html");
	}
	/**
	 * 转账待审核
	 */
	public void pending_list(){
		SearchParamBean search=getAndSetQueryParams();
		setAttr("listPage", RechargeModel.me.paginate(getParaToInt(0, 1), 10, search.getWord(),search.getDate1(),search.getDate2(),0));
		// 设置传入分页的url参数
		this.setAttr("append", search.getQueryString());
		this.render("pending_list.html");
	}
	/**
	 * 转账成功
	 */
	public void success_list(){
		SearchParamBean search=getAndSetQueryParams();
		setAttr("listPage", RechargeModel.me.paginate(getParaToInt(0, 1), 10, search.getWord(),search.getDate1(),search.getDate2(),1));
		// 设置传入分页的url参数
		this.setAttr("append", search.getQueryString());
		this.render("success_list.html");
	}
	/**
	 * 转账驳回
	 */
	public void returnback_list(){
		SearchParamBean search=getAndSetQueryParams();
		setAttr("listPage", RechargeModel.me.paginate(getParaToInt(0, 1), 10, search.getWord(),search.getDate1(),search.getDate2(),2));
		// 设置传入分页的url参数
		this.setAttr("append",  search.getQueryString());
		this.render("returnback_list.html");
	}
	/**
	 * 管理员直接充值
	 */
	public void adminrecharge_list(){
		SearchParamBean search=getAndSetQueryParams();
		setAttr("listPage", RechargeModel.me.paginate(getParaToInt(0, 1), 10, search.getWord(),search.getDate1(),search.getDate2(),null));
		// 设置传入分页的url参数
		this.setAttr("append", search.getQueryString());
		this.render("adminrecharge_list.html");
	}
	/**
	 * 在线支付成功
	 */
	public void onlinepay_success_list(){
		SearchParamBean search=getAndSetQueryParams();
		setAttr("listPage", RechargeModel.me.paginate(getParaToInt(0, 1), 10,search.getWord(),search.getDate1(),search.getDate2(),null));
		// 设置传入分页的url参数
		this.setAttr("append", search.getQueryString());
		this.render("onlinepay_success_list.html");
	}
	/**
	 * 未收到支付通知
	 */
	public void unnotify_list(){
		SearchParamBean search=getAndSetQueryParams();
		setAttr("listPage", RechargeModel.me.paginate(getParaToInt(0, 1), 10,search.getWord(),search.getDate1(),search.getDate2(),null));
		// 设置传入分页的url参数
		this.setAttr("append",  search.getQueryString());
		this.render("unnotify_list.html");
	}
}
